package com.reservation.controller.admin.home;

import com.reservation.dto.user.home.UpdateInfoDTO;
import com.reservation.result.Result;
import com.reservation.service.AdminHomeService;
import com.reservation.vo.admin.home.GetSystemInfo;
import com.reservation.vo.admin.home.RoomStatusCountVO;
import com.reservation.vo.staff.MeetingRoomVO;
import com.reservation.vo.user.home.GetTypeCountVO;
import com.reservation.vo.user.home.GetWeekCountArrVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "管理员首页相关接口")
@RestController
@RequestMapping("/api/admin")
@Slf4j
public class AdminHomeController {

    @Autowired
    private AdminHomeService adminHomeService;

    @PostMapping("/getSystemInfo")
    public Result<GetSystemInfo> getSystemInfo() {

        GetSystemInfo systemInfo = adminHomeService.getSystemInfo();
        return systemInfo == null ? Result.error("获取失败") : Result.success(systemInfo);
    }

    @PostMapping("/getTypeCount")
    public Result<List<GetTypeCountVO>> getTypeCount() {

        List<GetTypeCountVO> list = adminHomeService.getTypeCount();
        return Result.success(list);
    }

    @PostMapping("/getWeekCount")
    public Result<GetWeekCountArrVO> getWeekCount() {

        GetWeekCountArrVO arr = adminHomeService.getWeekCountArr();
        return Result.success(arr);
    }

    @PostMapping("/getStatusCount")
    public Result<List<RoomStatusCountVO>> getStatusCount() {
        log.info("获取会议室状态统计");
        List<RoomStatusCountVO> list = adminHomeService.getStatusCount();
        return Result.success(list);
    }

    /**
     * 获取会议室列表
     * @return 会议室列表
     */
    @PostMapping("/getMeetingRoomList")
    @ApiOperation("获取会议室列表")
    public Result<List<MeetingRoomVO>> getMeetingRoomList() {
        log.info("获取管理端会议室列表");
        List<MeetingRoomVO> meetingRoomList = adminHomeService.getMeetingRoomList();
        return Result.success(meetingRoomList);
    }

}
